/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-04-03
 * Time: 17:09
 */
public class Solution {
    public int lengthOfLongestSubstring(String string){
        char[] temp = string.toCharArray();
        int[] hash = new int[256];
        int left = 0;
        int right = 0;
        int result = 0;
        while(right < string.length()){
            hash[temp[right]]++;//进入窗口
            while(hash[temp[right]] > 1){
                hash[temp[left++]]--;//出窗口
            }
            result = Math.max(result, right - left + 1);
            right++;
        }
        return result;
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        int ret = solution.lengthOfLongestSubstring("abcabcbb");
        System.out.println(ret);
    }
}